package com.wlw.admin.openeye.mvp.presenter

import com.wlw.admin.openeye.base.BasePresenter
import com.wlw.admin.openeye.mvp.contract.RankContract
import com.wlw.admin.openeye.mvp.model.RankModel
import com.wlw.admin.openeye.net.exception.ExceptionHandle

class RankPresenter : BasePresenter<RankContract.View>(), RankContract.Presenter {

    private val rankModel by lazy {
        RankModel()
    }

    override fun requestRankList(apiUrl: String) {

        val disposable = rankModel.requestRankList(apiUrl).subscribe({
            mRootView?.apply {
                dismissLoading()
                setRankList(it.itemList)
            }
        }, { t ->
            mRootView?.apply {
                showError(ExceptionHandle.handleException(t), ExceptionHandle.errorCode)
            }
        })
        addSubscription(disposable)
    }
}